#  try 试一下  尝试
#  except  exception  异常
#  package   包

#  a
#  NameError : name 'a' is not defind

# dict = {}, dict['a']
# KeyError : 'a'

# 10/0

# list1
# IndexError: list index out of range

#  Exception 是所有异常的父类

try:
    list1 = [1,2,3]
    print(list1[3])
except KeyError as e: # except 异常名(Exception) as 返回值(异常的详细信息)
    print(e)
except Exception as e:
    print(e)
# if 第一次没能捕捉, 继续捕捉

print('-------------->')

try:
    list1 = [1,2,3]
    print(list1[3])
except IndexError as e: # except 异常名(Exception) as 返回值(异常的详细信息)
    print(e)
    print('1111')    # 第一次捕捉到 就完结
except Exception as e:
    print(e)
    print('2222')


print('异常下方代码')









